package com.pkx.cloud.fse7.dms.splitgrant.service.impl;

import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.pkx.cloud.fse7.dms.onegrant.entity.RpDmsTokenOneGrantView;
import com.pkx.cloud.fse7.dms.splitgrant.entity.RpDmsTokenSplitGrantView;
import com.pkx.cloud.fse7.dms.splitgrant.repo.RpDmsTokenSplitGrantViewMapper;
import com.pkx.cloud.fse7.dms.splitgrant.service.RpDmsTokenSplitGrantViewService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

/**
 *  服务实现类
 *
 * @author zhangwh
 * @since 2020-10-15
 */
@Service
public class RpDmsTokenSplitGrantViewServiceImpl extends ServiceImpl<RpDmsTokenSplitGrantViewMapper, RpDmsTokenSplitGrantView> implements RpDmsTokenSplitGrantViewService {

    /**
     * 分页列表
     *
     * @param
     * @return
     */
    @Override
    public Page<RpDmsTokenSplitGrantView> pageList(Page page, String startIssueDate,String endIssueDate,String staffName,String tokenId) throws ParseException {
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        Date startTime=new Date();
        Date endTime=new Date();
        if(StringUtils.isNotBlank(startIssueDate)&&StringUtils.isNotBlank(endIssueDate)){
            startTime = sdf.parse(startIssueDate);
            endTime  = sdf.parse(endIssueDate);
        }
        LambdaQueryWrapper<RpDmsTokenSplitGrantView> lambdaQueryWrapper = Wrappers.lambdaQuery(RpDmsTokenSplitGrantView.class)
                //人员名称
                .like(StringUtils.isNotBlank(staffName),RpDmsTokenSplitGrantView::getStaffName,staffName)
                //凭证号
                .eq(StringUtils.isNotBlank(tokenId),RpDmsTokenSplitGrantView::getTokenId,tokenId)
                //操作时间
                .between(StringUtils.isNotBlank(startIssueDate)&&StringUtils.isNotBlank(endIssueDate), RpDmsTokenSplitGrantView::getIssueDate,startTime,endTime);
        ;
        return page(page, lambdaQueryWrapper);
    }

    /**
     * 列表查询
     *
     * @param rpDmsTokenSplitGrantView
     * @return
     */
    @Override
    public List<RpDmsTokenSplitGrantView> listByEntity(RpDmsTokenSplitGrantView rpDmsTokenSplitGrantView) {
        LambdaQueryWrapper<RpDmsTokenSplitGrantView> lambdaQueryWrapper = Wrappers.lambdaQuery(RpDmsTokenSplitGrantView.class);
        return list(lambdaQueryWrapper);
    }

}
